{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_tcwq/template/public/ygcsslist.css">
<script type="text/javascript">
    $(function(){
        $("#frame-8").show();
        $("#yframe-8").addClass("wyactive");
    })
</script>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li class="active"><a href="{php echo $this->createWebUrl('storetype2')}">二级商家分类管理</a></li>
    <li><a href="{php echo $this->createWebUrl('addstoretype2')}">添加二级商家分类</a></li>
</ul>
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <input class="btn btn-default btn-danger" name="allselect" value="批量删除">
            <button class="btn btn-default btn-success" id="allnew">批量更新</button>
        </div>
    </div>
    <!-- 门店列表部分开始 -->
        <div class="panel panel-default">
            <div class="panel-heading">
                二级商家分类
            </div>
            <div class="panel-body" style="padding: 0px 15px;">
                <div class="row">
                    <table class="yg5_tabel col-md-12">
                        <tr class="yg5_tr1">
                           <th class="store_td1 col-md-1">
                              <input type="checkbox" class="allcheck" />
                              <span class="store_inp">全选</span>
                          </th>
                          <td class="store_td1 col-md-1">顺序</td>
                            <td class="col-md-2">商家分类</td>
                            <td class="col-md-2">二级分类名称</td>
<!--                             <td class="col-md-2">价格</td> -->
                            <td class="col-md-2">状态</td>
                            <td class="col-md-3">操作</td>
                        </tr>
                        {loop $list $row}
                        <tr class="yg5_tr2">
                         <td>
                          <input type="checkbox" name="test" value="{$row['id']}" id="{$row['state']}">
                          <span class="store_inp">选择</span>
                      </td>
                            <td><div>{$row['num']}</div></td>
                            <td>{$row['name']}</td>
                            <td>{$row['type_name']}</td>
 <!--                            <td>{$row['money']}</td> -->
  <td>{if $row['state']==1} <span class="label label-info">启用</span>{elseif $row['state']==2} <span class="label label-danger">禁用</span>{/if}</td>
                            <td><a class="btn btn-warning btn-xs" href="{php echo $this->createWebUrl('addstoretype2', array('id' => $row['id']))}" title="编辑">改</a>&nbsp;&nbsp;
                           <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal{$row['id']}">删</button>
                            </td>
                        </tr>
                         <div class="modal fade" id="myModal{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                        </div>
                        <div class="modal-body" style="font-size: 20px">
                            确定删除么？
                        </div>
                        <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <a href="{php echo $this->createWebUrl('storetype2', array('id' => $row['id']))}" type="button" class="btn btn-info" >确定</a>
                        </div>
                    </div>
                </div>
            </div>
                        {/loop}
                       
                    </table>
                </div>
            </div>
        </div>
    {$pager}
</div>
<script type="text/javascript">
    $(function(){
        $("input[name=allselect]").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的用户!');
                return false;
            }else if(confirm("确认要删除此用户?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=deletetype2&m=zh_tcwq",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);      
                        location.reload();
                    }
                })
               
            }
        });
        // 批量下架
        $("#allnew").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要更新的分类!');
                return false;
            }else if(confirm("确认要下更新此分类?")){
                var list = new Array();
                check.each(function(id,type){
                    id = $(this).val();
                    type = $(this).attr("id");
                    var obj = {};
                    obj.id = id;
                    obj.type = type
                    list.push(obj);
                });                
                console.log(list)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=AllUpdateStore&m=zh_tcwq",
                    dataType:"text",
                    data:{arr:list},
                    success:function(data){
                        console.log(data);      
                        location.reload();
                    }
                })
               
            }
        });
        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
        
    })
</script>
<!-- {template 'common/footer'} -->{template 'common/footer'}